package com.lesso.lpq.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.lpq.sunflower.domain.repository.EmployeeAttendanceRuleRepository;
import com.lesso.lpq.sunflower.infra.assembler.EmployeeAttendanceRuleAssembler;
import com.lesso.lpq.sunflower.model.EmployeeAttendanceRule;
import com.lesso.lpq.sunflower.pojo.dto.EmployeeAttendanceRuleDTO;
import com.lesso.lpq.sunflower.pojo.dto.EmployeeAttendanceRuleQueryDTO;
import com.lesso.lpq.sunflower.pojo.vo.DeviceVO;
import com.lesso.lpq.sunflower.pojo.vo.EmployeeAttendanceRuleVO;
import org.springframework.stereotype.Service;

/**
 * @ClassName : EmployeeAttendanceRuleDomainService
 * @Description :
 * @Author : 罗培棋
 * @Date: 2025-07-05 17:14
 */
@Service
public class EmployeeAttendanceRuleDomainService {
    private final EmployeeAttendanceRuleRepository employeeAttendanceRuleRepository;

    public EmployeeAttendanceRuleDomainService(EmployeeAttendanceRuleRepository repository) {
        this.employeeAttendanceRuleRepository = repository;
    }

    public Long save(EmployeeAttendanceRuleDTO dto) {
        EmployeeAttendanceRule entity = EmployeeAttendanceRuleAssembler.INSTANCE.dtoToEntity(dto);
        entity.setDelStatus(0);
        return employeeAttendanceRuleRepository.save(entity);
    }

    public Page<EmployeeAttendanceRuleVO> page(EmployeeAttendanceRuleQueryDTO dto) {
        return employeeAttendanceRuleRepository.getPageList(dto);
    }

    public Page<EmployeeAttendanceRuleVO> customPage(EmployeeAttendanceRuleQueryDTO dto) {
        return employeeAttendanceRuleRepository.getCustomPageList(dto);
    }

    public void update(EmployeeAttendanceRuleDTO dto) {
        employeeAttendanceRuleRepository.updateById(dto);
    }

    public void deleteById(Long id) {
        employeeAttendanceRuleRepository.removeById(id);
    }

    public EmployeeAttendanceRuleVO getByEmployeeId(String employeeId) {
        return employeeAttendanceRuleRepository.getByEmployeeId(employeeId);
    }
}